package com.lg.utils.hutool.io;

import cn.hutool.core.io.file.FileReader;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.List;

public class FileReaderTest {
    public static void main(String[] args) throws IOException {
        //默认UTF-8编码，可以在构造中传入第二个参数做为编码
        FileReader fileReader = new FileReader("C:/Users/imlg/Desktop/test1.txt");
        String result = fileReader.readString();
        List<String> strings = fileReader.readLines();
        System.out.println(result);
        System.out.println(strings);


        /**
         * 读取每行
         */
        BufferedReader reader = fileReader.getReader();
        try {
            String line = reader.readLine();
            System.out.println(line);
            while (line != null) {
                line = reader.readLine();
                System.out.println(line);
            }
        }finally {
            reader.close();
        }

        /**
         * 流 操作
         */
        BufferedInputStream inputStream = fileReader.getInputStream();



    }
}
